package com.murphy.springmvc.model;

import java.io.Serializable;

/**
 * @author moqinc
 * @date 2019/12/18 16:55
 * @version 1.0
 */
public class ResponseDTO<T> implements Serializable {
    //<editor-fold defaultstate="collapsed" desc="delombok">
    private String code;
    private String message;
    private T data;
    //</editor-fold>

    public ResponseDTO<T> build(T data) {
        this.code = "000000";
        this.message = "SUCCESS";
        this.data = data;
        return this;
    }

    public ResponseDTO<T> build(String code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
        return this;
    }

    @SuppressWarnings("all")
    public ResponseDTO() {
    }

    @SuppressWarnings("all")
    public String getCode() {
        return this.code;
    }

    @SuppressWarnings("all")
    public String getMessage() {
        return this.message;
    }

    @SuppressWarnings("all")
    public T getData() {
        return this.data;
    }

    @SuppressWarnings("all")
    public void setCode(final String code) {
        this.code = code;
    }

    @SuppressWarnings("all")
    public void setMessage(final String message) {
        this.message = message;
    }

    @SuppressWarnings("all")
    public void setData(final T data) {
        this.data = data;
    }

    @Override
    @SuppressWarnings("all")
    public boolean equals(final Object o) {
        if (o == this) return true;
        if (!(o instanceof ResponseDTO)) return false;
        final ResponseDTO<?> other = (ResponseDTO<?>) o;
        if (!other.canEqual((Object) this)) return false;
        final Object this$code = this.getCode();
        final Object other$code = other.getCode();
        if (this$code == null ? other$code != null : !this$code.equals(other$code)) return false;
        final Object this$message = this.getMessage();
        final Object other$message = other.getMessage();
        if (this$message == null ? other$message != null : !this$message.equals(other$message)) return false;
        final Object this$data = this.getData();
        final Object other$data = other.getData();
        if (this$data == null ? other$data != null : !this$data.equals(other$data)) return false;
        return true;
    }

    @SuppressWarnings("all")
    protected boolean canEqual(final Object other) {
        return other instanceof ResponseDTO;
    }

    @Override
    @SuppressWarnings("all")
    public int hashCode() {
        final int PRIME = 59;
        int result = 1;
        final Object $code = this.getCode();
        result = result * PRIME + ($code == null ? 43 : $code.hashCode());
        final Object $message = this.getMessage();
        result = result * PRIME + ($message == null ? 43 : $message.hashCode());
        final Object $data = this.getData();
        result = result * PRIME + ($data == null ? 43 : $data.hashCode());
        return result;
    }

    @Override
    @SuppressWarnings("all")
    public String toString() {
        return "ResponseDTO(code=" + this.getCode() + ", message=" + this.getMessage() + ", data=" + this.getData() + ")";
    }
}
